package sword;

import java.util.Arrays;

/**
 * @Author: 海琳琦
 * @Date: 2022/6/10 10:55
 * https://leetcode.cn/problems/ba-shu-zu-pai-cheng-zui-xiao-de-shu-lcof/
 */
public class Title45 {

    public String minNumber(int[] nums) {
        int n = nums.length;
        //比较字符串a+b和b+a的大小
        String[] arr = new String[n];
        for (int i = 0; i < n; i++) {
            arr[i] = String.valueOf(nums[i]);
        }
        Arrays.sort(arr, (a, b) -> ((a + b).compareTo(b + a)));
        StringBuilder result = new StringBuilder();
        for (int i = 0; i < n; i++) {
            result.append(arr[i]);
        }
        return result.toString();
    }

    public static void main(String[] args) {

    }
}
